﻿using System.Text.Json.Serialization;

namespace OpenPms.Data;
[Index(nameof(RoomTypeId), nameof(RoomNo), IsUnique = true)]
[Index(nameof(HotelId), nameof(RoomNo), IsUnique = true)]
[Index(nameof(HotelId), nameof(RoomTypeId), nameof(ArrangeIndex))]
public class TRoom : TBase
{
    [DatabaseGenerated(DatabaseGeneratedOption.None)]
    public Guid Id { get; set; } = Guid.Empty;
    [DisplayName("房型")]
    public Guid RoomTypeId { get; set; }
    [StringLength(32)]
    [Display(Name = "房号", Description = "可新增多个房号，只需逗号隔开")]
    public string RoomNo { get; set; } = default!;
    [DisplayName("排房顺序")]
    public int ArrangeIndex { get; set; }
    [DisplayName("特征")]
    public string? Desc { get; set; } = "";

    public bool IsDirty { get; set; }
    public ERoomStatus RoomStatus { get; set; }
    [Timestamp]
    [Obsolete]
    public byte[]? Version { get; set; }


    [ForeignKey(nameof(RoomTypeId))]
    [DisplayName("房型")]
    [JsonIgnore]
    public TRoomType RoomType { get; set; } = default!;
    [DisplayName("房型")]
    [NotMapped]
    public string RoomTypeName { get => RoomType?.Name ?? ""; }
    [JsonIgnore]
    [NotMapped]
    [Display(Name = "删除", Description = "选中， 将删除此数据")]
    public bool IsDelete { get; set; }
}
public enum ERoomStatus
{
    空 = 0,
    住,
    [Description("预分配")]
    预,
    [Description("维修房")]
    修,
    [Description("临时房")]
    临
}
